import type {PageParam, PageResult} from '@vben/request';
import type {Dayjs} from 'dayjs';

import {requestClient} from '#/api/request';
export namespace PerBusinessPartTimeApi {
  /** 兼职情况业务信息 */
  export interface BusinessPartTime {
    id: number; // 主键ID
    busiId?: string; // 业务主表id
    partTimeId: number; // 正式表ID，对应 per_part_time.id
    employeeId?: number; // 人员ID，对应 per_employee.id
    organizationName: string; // 社会兼职单位名称
    organizationType: string; // 单位性质
    position: string; // 担任职务
    paymentStatus: string; // 取酬情况
    partTimeDate: string | Dayjs; // 兼职时间
    approvedDepartment: string; // 批准部门
    status: number; // 记录状态（1：有效，0：无效）
    remarks: string; // 备注
    changeType: string; // 变更类型（add：新增，update：修改，delete：删除）
    changeContent: string; // 变更内容(JSON格式，记录变更前后对比，只有修改的时候记录)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态：0 待审核 1 审核通过 2 审核不通过
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询兼职情况业务分页 */
export function getBusinessPartTimePage(data: PageParam,desensitize: boolean,encrypt: boolean) {
  return requestClient.post<PageResult<PerBusinessPartTimeApi.BusinessPartTime>>('/per/business-part-time/page', data,{ desensitize,encrypt });
}

/** 查询兼职情况业务详情 */
export function getBusinessPartTime(id: number) {
  return requestClient.get<PerBusinessPartTimeApi.BusinessPartTime>(`/per/business-part-time/get?id=${id}`);
}

/** 新增兼职情况业务 */
export function createBusinessPartTime(data: PerBusinessPartTimeApi.BusinessPartTime) {
  return requestClient.post('/per/business-part-time/create', data);
}

/** 修改兼职情况业务 */
export function updateBusinessPartTime(data: PerBusinessPartTimeApi.BusinessPartTime) {
  return requestClient.put('/per/business-part-time/update', data);
}

/** 删除兼职情况业务 */
export function deleteBusinessPartTime(id: number) {
  return requestClient.delete(`/per/business-part-time/delete?id=${id}`);
}

/** 批量删除兼职情况业务 */
export function deleteBusinessPartTimeList(ids: number[]) {
  return requestClient.delete(`/per/business-part-time/delete-list?ids=${ids.join(',')}`)
}

/** 导出兼职情况业务 */
export function exportBusinessPartTime(params: any) {
  return requestClient.download('/per/business-part-time/export-excel', { params });
}

/** 根据业务主表id去查询业务数据 */
export function getPartTimeBusiId(data: any) {
  return requestClient.post<PerBusinessPartTimeApi.BusinessPartTime>(
    `/per/business-part-time/getPartTimeBusiId`,
    data,
  );
}

/** 获取当前登录人兼职情况 */
export function getCurrentPartTime(
  data: any,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PerBusinessPartTimeApi.BusinessPartTime[]>(
    '/per/business-part-time/getCurrentPartTime',
    data,
    {
      desensitize,
      encrypt,
    },
  );
}
